<template>
    <div>
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="标题">
                <el-input v-model="form.title"></el-input>
            </el-form-item>

            <el-form-item label="分类">
                <el-select v-model="form.type" placeholder="请选择类别">
                  <el-option  v-for="(item,index) in uid " :key="index" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
            </el-form-item>
            
            <el-form-item label="用时">
                <el-select v-model="form.time" placeholder="请选择用时">
                <el-option label="1" value="1"></el-option>
                <el-option label="2" value="2"></el-option>
                <el-option label="3" value="3"></el-option>
                <el-option label="5" value="5"></el-option>
                <el-option label="10" value="10"></el-option>
                </el-select>
            </el-form-item>

            <mavonEditor
                style="max-height:300px;overflow-y:scroll;"
                v-model="form.content">
            </mavonEditor>

            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                <el-button @click="quxiao">取消</el-button>
            </el-form-item>
            </el-form>
            {{uid}}
    </div>
</template>

<script>
import { mavonEditor } from "mavon-editor";
import "mavon-editor/dist/css/index.css";
import { mapActions, mapState } from "vuex";
export default {
  props: ["newincreased", "checktest"],
  data() {
    return {
      form: {}
    };
  },
  mounted() {
    this.uidapi();
    if (!this.checktest) {
      return;
    } else {
      this.form = this.checktest;
    }
  },
  methods: {
    ...mapActions("msbd", ["Modify", "Xuigai", "uidapi"]),
    // 修改或者新增
    onSubmit() {
      if (!this.form.id) {
        let from = this.form;
        this.Modify(from);
        this.newincreased();
        this.form = {};
      } else {
        this.Xuigai(this.form);
        this.newincreased();
        this.form = {};
      }
    },
    quxiao() {
      // console.log(this.$parent)
      console.log(this.$parent);
      this.$parent.getlisthost()
    }
  },
  computed: {
    ...mapState("msbd", ["uid"])
  },
  components: {
    mavonEditor
  }
};
</script>

<style scoped>
</style>